package com.sline.test;

import java.math.BigInteger;

public class ZeroCount {
    public static void main(String[] args) {
        BigInteger bi = new BigInteger("1");
        for (int i = 1; i <= 1000; i++) {
            bi = bi.multiply(new BigInteger(i + ""));
        }
        
        String str = bi.toString();
        System.out.println("结果是" + str);
        int zeroCount = 0;
        for (int i = 0; i < str.length(); i++) {
            if ('0' == str.charAt(i)) {
                zeroCount = zeroCount + 1;
            }
        }

        System.out.println("0的个数有" + zeroCount + "个");

        StringBuilder sb = new StringBuilder(str);
        sb.reverse();
        String reverseStr = sb.toString();
        System.out.println("reverseStr结果是" + reverseStr);
        int endZeroCount = 0;
        for (int i = 0; i < reverseStr.length(); i++) {
            if ('0' == reverseStr.charAt(i)) {
                endZeroCount = endZeroCount + 1;
            } else {
                break;
            }
        }

        System.out.println("末尾0的个数有" + endZeroCount + "个");
    }
}
